#include "Keyboard.h" #define SENSOR_PIN A0 // Arduino pin connected to sound sensor's pin int sensorValue; void setup() { Serial.begin(9600); // initialize serial pinMode(SENSOR_PIN, INPUT); // set arduino pin to input mode sensorValue = analogRead(SENSOR_PIN); } void loop() { sensorValue = analogRead(SENSOR_PIN); // read new sensor value Serial.println(sensorValue); if (sensorValue > 70) { Serial.println("The sound has been detected"); // control LED arccoding to the toggled state Keyboard.press('w'); } else{ Keyboard.releaseAll(); } }